/**   
* @Title: StudentImpl.java 
* @Package cn.hdmis.dao.imp 
* @Description: TODO
* @author pnwazgx@163.com   
* @date 2011-3-28 下午10:27:15 
* @version V1.0   
*/
package cn.hdmis.dao.impl;

import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.hibernate.Query;

import cn.hdmis.dao.StudentDao;
import cn.hdmis.entity.Guardian;
import cn.hdmis.entity.Student;
import cn.hdmis.entity.Grade;
import cn.hdmis.entity.Teacher;

/** 
 * @ClassName: StudentImpl 
 * @Description: TODO
 * @author pnwzgx@163.com
 * @date 2011-3-28 下午10:27:15 
 *  
 */

public class StudentDaoImpl extends BaseDaoImp<Student> implements StudentDao {
	public int countStudent() {
		int count = (Integer) this.getSession().createQuery("select count(*) from Student").uniqueResult();
		return count;
	}
	/* (非 Javadoc) 
	 * <p>Title: countStudent</p> 
	 * <p>Description: </p> 
	 * @param status
	 * @return 
	 * @see cn.hdmis.dao.StudentDao#countStudent(java.lang.Boolean) 
	 */
	@Override
	public int countStudent(Boolean status) {
		int count;
		if(status){
			count = (Integer) this.getSession().createQuery("select count(*) from Student where status=1").uniqueResult();
		}else{
			count = (Integer) this.getSession().createQuery("select count(*) from Student where status=0").uniqueResult();
		}
		// TODO Auto-generated method stub
		return count;
	}

	/* (非 Javadoc) 
	 * <p>Title: countStudent</p> 
	 * <p>Description: </p> 
	 * @param clazz
	 * @return 
	 * @see cn.hdmis.dao.StudentDao#countStudent(cn.hdmis.entity.StudentsClass) 
	 */
	@Override
	public int countStudent(Grade clazz) {
		// TODO Auto-generated method stub
		Set<Grade> stc = new HashSet<Grade>();
		stc.add(clazz);
		Query query = this.getSession().createQuery("selct count(*) from Student where status='1' and stclassSet =:stc");
		query.setParameter("stc", stc);
		return (Integer)query.uniqueResult();
	}

	/* (非 Javadoc) 
	 * <p>Title: countStudent</p> 
	 * <p>Description: </p> 
	 * @param age
	 * @return 
	 * @see cn.hdmis.dao.StudentDao#countStudent(java.lang.Integer) 
	 */
	@Override
	public int countStudent(Integer age) {
		// TODO Auto-generated method stub
		Query query = this.getSession().createQuery("selct count(*) from Student where status='1' and age =:age");
		query.setParameter("age", age);
		return (Integer)query.uniqueResult();
	}

	/* (非 Javadoc) 
	 * <p>Title: findByGuardian</p> 
	 * <p>Description: </p> 
	 * @param guardian
	 * @return 
	 * @see cn.hdmis.dao.StudentDao#findByGuardian(cn.hdmis.entity.Guardian) 
	 */
	@Override
	public Student findByGuardian(Guardian guardian) {
		// TODO Auto-generated method stub
		return null;
	}

	/* (非 Javadoc) 
	 * <p>Title: findByTeacher</p> 
	 * <p>Description: </p> 
	 * @param teacher
	 * @return 
	 * @see cn.hdmis.dao.StudentDao#findByTeacher(cn.hdmis.entity.Teacher) 
	 */
	@Override
	public List<Student> findByTeacher(Teacher teacher) {
		// TODO Auto-generated method stub
		return null;
	}

	/* (非 Javadoc) 
	 * <p>Title: findByTeacher</p> 
	 * <p>Description: </p> 
	 * @param teacher
	 * @param begin
	 * @param end
	 * @return 
	 * @see cn.hdmis.dao.StudentDao#findByTeacher(cn.hdmis.entity.Teacher, java.util.Date, java.util.Date) 
	 */
	@Override
	public List<Student> findByTeacher(Teacher teacher, Date begin, Date end) {
		// TODO Auto-generated method stub
		return null;
	}

	/* (非 Javadoc) 
	 * <p>Title: removeStudent</p> 
	 * <p>Description: </p> 
	 * @param student 
	 * @see cn.hdmis.dao.StudentDao#removeStudent(cn.hdmis.entity.Student) 
	 */
	@Override
	public void removeStudent(Student student) {
		// TODO Auto-generated method stub

	}

}
